/*
 * DefaultPreferenceSet.java
 *
 * Created on January 4, 2006, 12:20 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.jxta.myjxta.util.preferences;

import info.clearthought.layout.TableLayout;
import java.awt.Dimension;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.JXTitledPanel;

/**
 *
 * @author polo
 */
public class DefaultPreferenceSet extends PreferenceSet{
    private String error = null;
    /** Creates a new instance of DefaultPreferenceSet */
    public DefaultPreferenceSet() {
    }
    
    public void init() {}
    public JComponent getUI() {
        
        TableLayout tl;
        Dimension d = MyPreferenceManager.stringToDimension(this.getAttribute("dimension"));
        if(d != null) {
            double[][] sizes = {{ d.getWidth() },{d.getHeight()}};
            tl = new TableLayout(sizes);
        }else{
            double[][] sizes = {{ TableLayout.FILL },{TableLayout.FILL}};
            tl = new TableLayout(sizes);
        }
        //double[][] sizes = {{ d.getWidth() },{d.getHeight()}};
        
        JXPanel p = new JXPanel(tl);
        
        JXTitledPanel panel = new JXTitledPanel("Default Preference Set Panel");
        JLabel label = new JLabel();
        if(!error.equals("")) {
            label.setText(error);
        }else{
            label.setText("An error has occured in the XML prefs file for this preference set.");
        }
        label.setText("An error has occured in the XML prefs file for this preference set.");
        JPanel pp = new JPanel();
        pp.add(label);
        panel.add(pp);
        
        p.add(panel,"0,0");
        
        return p;
    }
    
    public void setErrorMessage(String error) {
        this.error = error;
    }
    
    public void destroy() {}
}
